#!/usr/bin/env python3
# -*- coding: utf-8 -*-

'分组'

import re

if __name__ == '__main__':
    rm = re.match(r'(\d{3})-(\d{3,8})', '012-12345')
    if rm:
        print(True) # True
        # 分组
        print(rm.groups()) # ('012', '12345')
        print(rm.group(0))  # 012-12345
        print(rm.group(1))  # 012
        print(rm.group(2))  # 2345
    else:
        print(False)

    # 贪婪匹配与非贪婪匹配
    gp1 = re.match(r'(\d+)(0*)', '102300').groups()
    print(gp1)  # ('102300', '')
    gp2 = re.match(r'(\d+?)(0*)', '102300').groups()
    print(gp2)  # ('1', '0')